package io.github.cocoa.module.socket.dal.mysql.sample;

import io.github.cocoa.framework.common.pojo.PageResult;
import io.github.cocoa.framework.mybatis.core.mapper.BaseMapperX;
import io.github.cocoa.framework.mybatis.core.query.LambdaQueryWrapperX;
import io.github.cocoa.module.socket.controller.admin.sample.vo.SampleInfoExportReqVO;
import io.github.cocoa.module.socket.controller.admin.sample.vo.SampleInfoPageReqVO;
import io.github.cocoa.module.socket.dal.dataobject.sample.SampleInfoDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 示例信息 Mapper
 *
 * @author James
 */
@Mapper
public interface SampleInfoMapper extends BaseMapperX<SampleInfoDO> {

    default PageResult<SampleInfoDO> selectPage(SampleInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SampleInfoDO>()
                .likeIfPresent(SampleInfoDO::getName, reqVO.getName())
                .eqIfPresent(SampleInfoDO::getStatus, reqVO.getStatus())
                .orderByDesc(SampleInfoDO::getId));
    }

    default List<SampleInfoDO> selectList(SampleInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<SampleInfoDO>()
                .likeIfPresent(SampleInfoDO::getName, reqVO.getName())
                .eqIfPresent(SampleInfoDO::getStatus, reqVO.getStatus())
                .orderByDesc(SampleInfoDO::getId));
    }

}
